import { useState, useEffect } from "react";


let timer: string | number | NodeJS.Timeout | null | undefined = null;

const CutDown = () => {
  const [number, setNumber] = useState(0);
  const [time, setTime] = useState(0);

  useEffect(() => {
    timer = setInterval(() => {
      setTime((prev) => prev + 1);
    }, 1000);
    return () => {
      if (timer) clearInterval(timer);
    };
  }, []);

  return (
    <div
      style={{
        display: "flex",
        justifyContent: "space-between",
        alignItems: "center",
      }}
    >
      <div>用时：{time}秒</div>
    </div>
  );
};

export default CutDown;
